﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Library.Interfaces;
using Microsoft.AspNetCore.Mvc;

namespace MvcMovie.Controllers
{
    public class DITestController : Controller
    {
        private readonly IOperation _operation;
        private readonly IOperationTransient _operationTransient;
        private readonly IOperationScoped _operationScoped;
        private readonly IOperationSingleton _operationSingleton;

        public DITestController(IOperation operation,
            IOperationTransient operationTransient,
            IOperationScoped operationScoped,
            IOperationSingleton operationSingleton)
        {
            _operation = operation;
            _operationTransient = operationTransient;
            _operationScoped = operationScoped;
            _operationSingleton = operationSingleton;
        }


        public IActionResult Index()
        {
            ViewBag.AddTransient = _operation.OperationId;
            ViewBag.Date = _operation.GetList("");
            return View();
        }

        public IActionResult Test()
        {

            ViewBag.AddTransient = _operation.OperationId;
            ViewBag.Date = _operation.GetList("");


            ViewBag._operationTransient = _operationTransient.OperationId;
            ViewBag._operationScoped = _operationScoped.OperationId;
            ViewBag._operationSingleton = _operationSingleton.OperationId;

            return View();
        }

        public IActionResult Test1([FromServices]IOperationTransient operationTransient,
            [FromServices]IOperationScoped operationScoped,
            [FromServices]IOperationSingleton operationSingleton)
        {

            ViewBag.AddTransient = _operation.OperationId;
            ViewBag.Date = _operation.GetList("");


            ViewBag._operationTransient = operationTransient.OperationId;
            ViewBag._operationScoped = operationScoped.OperationId;
            ViewBag._operationSingleton = operationSingleton.OperationId;

            return View();
        }
    }
}